// import {getUserRoles } from '../../utils/request';
/* eslint-disable import/no-mutable-exports */
let CURRENT = "NULL";

// console.log('CURRENT',CURRENT);
/**
 * use  authority or getAuthority
 * @param {string|()=>String} currentAuthority
 */
const renderAuthorize = Authorized => currentAuthority => {
  // console.log("---执行",currentAuthority);
  if (currentAuthority) {
    // console.log('进入1');
    if (typeof currentAuthority === "function") {
      CURRENT = currentAuthority();
    }
    if (
      typeof currentAuthority === "string" ||
      currentAuthority instanceof Array
    ) {
      CURRENT = currentAuthority;
    }
  } else {
    // console.log('进入2');
    CURRENT = 'NULL';
  }
  // console.log('CURRENT2',CURRENT);
  return Authorized;
};

export { CURRENT };
export default Authorized => renderAuthorize(Authorized);
